# coding=utf-8
'''
Created on 2018年4月17日

@author: lijie
'''
from library.page_element.oa.timesheet_page import BtnProjectList, \
    LstProjectProcess, LstSubProcess, TxtTansaction, BtnSend, CobProjectProcess, \
    CobSubProcess, TxtTime


class TimeSheetPage:
    def __init__(self,dr):
        self.dr=dr
        
    def click_project(self):
        BtnProjectList(self.dr).click()
        
    def chooseProcess(self,item):
        CobProjectProcess(self.dr).click() 
        js = 'document.querySelectorAll("select")[0].style.display="block";'
        self.dr.execute_script(js)       
        LstProjectProcess(self.dr).select_by_item_text(item)
        
    def chooseSubProcess(self,item):
        CobSubProcess(self.dr).click()
        js = 'document.querySelectorAll("select")[1].style.display="block";'
        self.dr.execute_script(js)
        LstSubProcess(self.dr).select_by_item_text(item)
        
    def setTrasctions(self,tran_txt):
        TxtTansaction(self.dr).input(tran_txt)
        
    def setTime(self,time_txt):
        TxtTime(self.dr).input(time_txt)
    
    def submitTimeSheet(self):
        BtnSend(self.dr).should_exist()   # 不能真的发送，改成判断它应该存在